/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package model;

import java.util.ArrayList;
import java.util.Iterator;

/**
 *
 * @author belal
 */
public class UserCartBean {

    ArrayList<ProductBean> product = new ArrayList<ProductBean>();

    public void addItem(ProductBean bean) {
        product.add(bean);
    }

    public void removeItem(int productId) {
        Iterator it = product.iterator(); //iterator
        while (it.hasNext()) {
            System.out.println(it.next());
            ProductBean pbean=(ProductBean) it.next();
            if(pbean.getpId()==productId){
                product.remove(pbean);
            }
            }
        }
    public ArrayList<ProductBean> getItems() {
        ArrayList<ProductBean> newProduct=new ArrayList<ProductBean>();
       Iterator it = product.iterator(); //iterator
        while (it.hasNext()) {
            ProductBean pbean=(ProductBean) it.next();
            newProduct.add(pbean);
            }
        return newProduct;
        }
        
    }